package test

import (
	// "github.com/go-martini/martini"
	"fmt"
	"net/http"
	"server/lib/Imartini"
	"server/lib/cookie"
	"server/lib/session"
)

func getcookie(res http.ResponseWriter, req *http.Request, mlog *Imartini.Mlog, sess session.SESS) string {
	cookies, err := req.Cookie("test2")
	mlog.Printf("%s:%s", cookies.String(), err)
	fmt.Fprintf(res, "%s", "...")

	stmp := cookie.Secure_get(req, "test", "")
	// stmp := ""
	return cookies.Value + ":" + stmp + ":" + cookies.Value
}

func setcookie(res http.ResponseWriter, req *http.Request, mlog *Imartini.Mlog, sess session.SESS) string {
	cookie.Set(res, "test2", "{name:'negocat00', value:'1'}")
	cookie.Secure_set(res, "test", "{name:'negocat00的', value:'1'}", "")
	// cookie.Value
	return "stcookie ok"
}

func getsession(res http.ResponseWriter, req *http.Request, mlog *Imartini.Mlog, sess session.SESS) string {
	// s := session.GetAll(req)
	ret := fmt.Sprintf("%s", sess)
	return ret
}

func setsession(res http.ResponseWriter, req *http.Request, mlog *Imartini.Mlog, sess session.SESS) string {
	sess["hello"] = "world"
	// cookie.Value
	return "setsession ok"
}

func delsession(res http.ResponseWriter, req *http.Request, mlog *Imartini.Mlog, sess session.SESS) string {
	delete(sess, "hello")
	// session.Del(req, "hello")
	// cookie.Value
	return "delsession ok"
}
